﻿using System;
using Xtee.Core.Client;
using Xtee.Core.Envelope;

namespace Client
{ 
    public class CommandLoggingInterceptor : ICommandInterceptor
    {

        public void Begin(ISoapEnvelope requestEnvelope)
        {
             
        }

        public void BeforeMakingHttpRequest(ISoapEnvelope requestEnvelope, AboutCommand aboutCommand)
        {
            
        }

        public void End(ISoapEnvelope requestEnvelope, SoapEnvelope responseEnvelope, AboutCommand aboutCommand, Exception exception = null)
        {
            Console.WriteLine("Started : {0}", aboutCommand.Started);
            Console.WriteLine("Service : {0}", requestEnvelope.Header.Service);
            Console.WriteLine("Execution : {0}", exception == null ? "was a success" : exception.Message);
            Console.WriteLine("Took : {0}", aboutCommand.ProccessingTime);
            Console.WriteLine("Personal code :{0}", requestEnvelope.Header.GetUserId());
            Console.WriteLine("Request path : {0}", aboutCommand.Files.OfRequest);
            Console.WriteLine("Response path : {0}", aboutCommand.Files.OfResponse);
            Console.WriteLine("RequestId: {0}", requestEnvelope.Header.Id);

        }

    }
}